package com.ceprei.ds.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ceprei.common.constants.SysUserConstants;
import com.ceprei.domain.modules.sys.entity.User;
import com.ceprei.ds.modules.sys.mapper.UserMapper;
import com.ceprei.ds.modules.sys.service.IUserService;
import com.ceprei.gui.service.BasicServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @author zhou minghao
 * @date 2024/11/29
 * @description
 */
@Service
@Slf4j
public class IUserServiceImpl extends BasicServiceImpl<UserMapper, User> implements IUserService {

    /**
     * 需要根据业务情况进行修改
     *
     * @param username 用户名
     * @return
     */
    @Override
    @Cacheable(key = "#username")
    public User getUserInfoByUserName(String username) {
        LambdaQueryWrapper<User> eq = new LambdaQueryWrapper<User>()
                .eq(User::getLoginName, username)
                .eq(User::getStatus, SysUserConstants.STATUS_START_UP);
        return getOne(eq);
    }
}
